#include "window.hpp"

//Constructor
Window :: Window()
{
	window = new sf::RenderWindow();
	width = 800;
	height = 800;
	aa = 32;
	windowname = "";
	windowmode = 7;
}

//Create Window
void Window :: createWindow()
{
	window->Create(sf::VideoMode(width,height,aa),windowname,windowmode);
}

//Set Windowinformations (Height,Width,Anti-Aliasing)
void Window :: WindowGetInformation()
{
	int eingabe;

	//Height
	cout << "Height: " << endl;
	cin >> eingabe;
	height = eingabe;
	//Width
	cout << "Widht: " << endl;
	cin >> eingabe;
	width = eingabe;
	//Anti-Aliasing
	cout << "Anti-Aliasing: " << endl;
	cin >> eingabe;
	aa = eingabe;
	//Windowname
	cout << "Windowname: " << endl;
	cin >> eingabe;


	//Create the new Window
	window->Create(sf::VideoMode(width,height,aa),"Hey");
}

//Gameloop
void Window :: displayWindow()
{

	//Gameloop
	while(window->IsOpened())
	{
		//EventLoop
		WindowEvents();


		window->Display();
	}
}

//Eventloop
void Window :: WindowEvents()
{

	//Eventloop
	while(window->GetEvent(ev1))
	{
		//close the window
		if(ev1.Type == sf::Event::Closed)
			window->Close();
		
		//change window informations if 'O' is pressed
		if(ev1.Type == sf::Event::KeyPressed)
		{
			if(ev1.Key.Code == sf::Key::O)
			{
				window->Close();
				WindowGetInformation();
			}
		}
	}
}

//delete the instance
void Window :: destroyWindow()
{
	delete window;
}